<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%@ taglib uri="/WEB-INF/struts-html" prefix="html"%>
<%@ taglib uri="/WEB-INF/struts-bean" prefix="bean"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%request.setAttribute("ctx",request.getContextPath()); %>
<html>
<head>
<link href="${ctx}/extend/css/style.css" rel="stylesheet"
	type="text/css" />
<script src="${ctx}/extend/js/jquery/jquery.js" type="text/javascript"></script>
<script src="${ctx}/extend/js/dutil/DUtil.js" type="text/javascript"></script>
<script src="${ctx}/extend/css/css.js" type="text/javascript"></script>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link href="${ctx}/css/style.css" rel="stylesheet" type="text/css" />
<script src="${ctx}/js/common.js" type="text/javascript"></script>
<script src="${ctx}/js/check.js" type="text/javascript"></script>
<title>Edit User</title>
<script type="text/javascript">
   function editUser(){
      	var userName = document.getElementById("userName");
   		var ebayActArray = document.getElementsByName("userPO.ebayActIdArray");
   		if(checkNull(userName)){
			alert("userName can not be null!");
			document.getElementById("userName").focus();
			return false;
		}
		/* if(checkAllNone(ebayActArray)){
			alert("Please choose a ebay account!");
			return false;
		} */
		
		var pwd1 = document.getElementById("password1").value;
   		var pwd2 = document.getElementById("password2").value;
   		
   		if(null == pwd1 || "" == pwd1){
   			//alert("密码不能为空！");
   			//return true;
   		} else {
   			if(pwd1 != pwd2){
  	   			alert("两次输入的密码不相等！");
   			return false;
   			} 
   		}
		
		var mdForm=document.getElementById("mdForm");
       	mdForm.action="${ctx}/admin/editUser";
        mdForm.submit();
    }
	
   function doFresh() {
        if (getFresh()){
        	document.forms[0].submit();
        } 
    }

</script>
</head>


<body class="maintable">
	<form name="merchandiseForm" method="POST" id="mdForm" action="saveMd"
		enctype="multipart/form-data">
		<div class="dclass_container">
			<div class="dclass_container_header">
				<div class="dclass_container_title">Add User</div>
			</div>

			<div class="dclass_container_content">
				<table width="100%" border="0" cellpadding="0" cellspacing="1"
					bgcolor="#9FD6FF">

					<tr>
						<td width="20%" class="formtitle">User Name:<span
							class="fontred">*</span><br /></td>
						<td width="30%" class="formtd"><input type="hidden"
							name="userPO.userId" id="userName" value="${userPO.userId}" />${userPO.userName}
						</td>
					</tr>
					<tr>
						<td width="20%" class="formtitle">Role:</td>
						<td width="30%" class="formtd"><select name="userPO.roleId" <c:if test="${userPO.userId == User.userId}">disabled="disabled"</c:if>
							style="width: 145px">
								<c:forEach var="cvar" items="${roleList}">
									<option
										<c:if test = "${cvar.roleId == userPO.roleId}">selected</c:if>
										value="${cvar.roleId}">${cvar.roleName}</option>
								</c:forEach>
						</select></td>
					</tr>
					
					<tr>
						<td width="20%" class="formtitle">新密码(此处为空默认不更改密码):</td>
						<td width="30%" class="formtd"><input name="userPO.password"
							type="password" id="password1" class="inputform" value=""></td>
					</tr>
					<tr>
						<td width="20%" class="formtitle">再次输入新密码(如果新密码不为空,此格必填):</td>
						<td width="30%" class="formtd"><input 
							type="password" id="password2" class="inputform" value="">（请输入相同的密码）</td>
					</tr>

				</table>
				<br style="line-height: 5px;" /> <br style="line-height: 5px;" />
				<div style="padding: 0.3em; text-align: center">
					<input type="button" class="btn1" value="Save"
						onclick="javascript:editUser();" />&nbsp; <input type="button"
						class="btn1" value="Return"
						onclick="javascript:window.history.back();" />
				</div>
			</div>
		</div>
	</form>
</body>
</html>